package com.bilibili.bilibili.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bilibili.bilibili.R;
import com.bilibili.bilibili.bean.EveryoneSeekBean;
import com.bumptech.glide.Glide;

import java.util.List;

/**
 * Created by Sir 冯  lenovo on 2017/3/16.
 */

public class EveryoneSeekListViewAdapter extends BaseAdapter {
    private Context context;

    public EveryoneSeekListViewAdapter(Context context, List<EveryoneSeekBean.DataBean.ItemsBean.ArchiveBean> list) {
        this.context = context;
        this.list = list;
    }

    private List<EveryoneSeekBean.DataBean.ItemsBean.ArchiveBean> list;
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView==null){
            convertView= LayoutInflater.from(context).inflate(R.layout.item_everyone_seek,parent,false);
            holder=new ViewHolder();
            holder.imageView= (ImageView) convertView.findViewById(R.id.item_everyone_seek_image);
            holder.text_title= (TextView) convertView.findViewById(R.id.text_title);
            holder.text_author= (TextView) convertView.findViewById(R.id.text_author);
            convertView.setTag(holder);
        }else {
            holder= (ViewHolder) convertView.getTag();
        }
        Glide.with(context).load(list.get(position).getCover()).into(holder.imageView);
        holder.text_title.setText(list.get(position).getTitle());
        holder.text_author.setText(list.get(position).getAuthor());
        return convertView;
    }
    class ViewHolder{
        ImageView imageView;
        TextView text_title,text_author;
    }
}
